/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-09-11
 * Time: 8:31
 */
public class plural {
    private double real;
    private double imaginary;
    //初始化
    public plural(double real, double imaginary) {
        this.real = real;
        this.imaginary = imaginary;
    }
    //加法
    public static plural add(plural plural1, plural plural2) {
        return new plural(plural1.real+plural2.real, plural1.imaginary+plural2.imaginary);
    }
    //减法
    public static plural sub(plural plural1, plural plural2) {
        return new plural(plural1.real-plural2.real, plural1.imaginary-plural2.imaginary);
    }
    //乘法
    public static plural mul(plural plural1, plural plural2) {
        return new plural(plural1.real*plural2.real-plural1.imaginary*plural2.imaginary,
                plural1.real*plural2.imaginary+plural2.real*plural1.imaginary);
    }
    //获取实部
    public double getReal() {
        return this.real;
    }
    //获取虚部
    public double getImaginary() {
        return this.imaginary;
    }
}
